﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SchoolManagementSystem.Controls;
using CoreData;
namespace SchoolManagementSystem.Details
{
    public partial class Student_HistoryUC : DetailUC
    {
        public Student_HistoryUC()
        {
            InitializeComponent();
            this.ObjectName = "lịch sử";
            this.Code = "StudentHistory";
            this.Type = new Student_History();
        }



        protected override long DetailDisplay()
        {
            Student_History data = new Student_History();
            if (ID > 0)
            {
                data = (Student_History)RegisterService.RegisterServices.StudentHistoryService.GetByID(ID);

            }

            memoEdit_content.Text = data.Content;

            return ID;

        }

        protected override long Save()
        {
            Student_History data = new Student_History();
            if (ID > 0)
            {
                data = (Student_History)RegisterService.RegisterServices.StudentHistoryService.GetByID(ID);

            }

            data.Content = memoEdit_content.Text;
            data.StudentID = long.Parse(SearchString.Replace("'", "").Replace("StudentID=", "").Trim());

            ID = RegisterService.RegisterServices.StudentHistoryService.Save(data);

            return ID;
        }


        public override bool Delete(long SelectedID)
        {
           
                //return RegisterService.RegisterServices.BranchService.Delete(RegisterService.RegisterServices.BranchService.GetByID(SelectedID));
            return RegisterService.RegisterServices.StudentHistoryService.UpdateIsDelete(RegisterService.RegisterServices.StudentHistoryService.GetByID(SelectedID));
            
        }

        private void Student_HistoryUC_Load(object sender, EventArgs e)
        {
            AddTextChanged(this.groupControl1.Controls);
        }

    }
}
